読み取り専用

フォーラムは現在、読み取り専用のアーカイブとなっています。.

バグ報告やプラットフォームに関する質問はこちら → [email protected]

私たちのコミュニティはDiscordとYouTubeで活動しています。ぜひ参加してください!

ご参加ください Discord YouTube

SQX’s new method? SL/PT based on fixed pips or ATR value.

5件の返信

イーストピース

Customer、bbp_participant、community、sq-ultimate、298件の返信。.

プロフィールを表示

7年前 #240480

In the TS code, I found the SL/PT calculation is different between SQX and SQ 3.8.

SQX style:

if(MarketPosition > 0) then begin
BarsSinceEntry = 0 の場合、開始
LongSL = 0;
LongTrailingStop = 0;
終了;;
LongSLPlaced = false;
//ストップロス
LongSL = EntryPrice – 450.0 * tickSize;
LongSL = SQ_CorrectMinMaxSLPT(LongSL, MinimumSLPT, MaximumSLPT, true);

Sell(“LongSL”) next bar at LongSL stop;
LongSLPlaced = true;

// ProfitTarget
PT = EntryPrice + 955.0 * tickSize;
PT = SQ_CorrectMinMaxSLPT(PT, MinimumSLPT, MaximumSLPT, false);
Sell(“LongPT”) next bar at PT limit;

…

SQ 3.8 style

{
Tradestation Strategy of 25_03_2017Strategy 1.3073

Generated by StrategyQuant version 3.8.1
Generated at Wed Apr 17 08:20:00 GMT 2019

Tested on SHEF_RB, H1, 27.03.2009 – 03.03.2017
}

入力:

//——————————————————————
// Strategy Options
MaxTradesPerDay(10),
ExitOnClose(false),
LimitSignalsToRange(false),
TimeRangeFrom(0900),
TimeRangeTo(1455),

//——————————————————————
// Money Management Parameters
// MoneyManagementType:
//  0 – fixed size (from TradeSize)
//  1 – risk fixed % of account equity
//  2 – risk fixed amount in $
//——————————————————————
CapitalSize(10000),
MoneyManagementType(0),
TradeSize(1.0),
SizeRounding(0),
RiskPerTrade(0), // in % or in $, depending on MM type
MaxTradeSize(0);

vars:
tickSize(MinMove/PriceScale)、,
PriceLevel(0), NumberOfShares(0),
LongSL(0),LongPT(0),
ShortSL(0),ShortPT(0),
SLSize(0),
LongEntryCondition(false),ShortEntryCondition(false),
LongExitCondition(false),ShortExitCondition(false);

// ——————————————
// ENTRY RULES
// ——————————————
if(LimitSignalsToRange = false or (Time >= TimeRangeFrom and Time < TimeRangeTo)) then begin

// Long ——–
if(MaxTradesPerDay = 0 or EntriesToday(Date) < MaxTradesPerDay) then begin
LongEntryCondition = (High[18] < Open[1]);
if(LongEntryCondition = true) then begin
SLSize = Round2Fraction((5.88 * AvgTrueRange(109)[0]));
NumberOfShares = SQ_MoneyManagement(CapitalSize, SLSize, MoneyManagementType, TradeSize, SizeRounding, RiskPerTrade, MaxTradeSize);

Buy(“LongMarket”) NumberOfShares shares next bar at market;
終了;;
終了;;

// Short ——–
if(MaxTradesPerDay = 0 or EntriesToday(Date) < MaxTradesPerDay) then begin
ShortEntryCondition = (Low[18] > Open[1]);
if(ShortEntryCondition = true) then begin
SLSize = Round2Fraction((5.88 * AvgTrueRange(109)[0]));
NumberOfShares = SQ_MoneyManagement(CapitalSize, SLSize, MoneyManagementType, TradeSize, SizeRounding, RiskPerTrade, MaxTradeSize);
SellShort(“ShortMarket”) NumberOfShares shares next bar at market;
終了;;
終了;;
終了;;

// ——————————————
// MANAGE TRADE & EXIT RULES
// ——————————————

// Long ——–
if(MarketPosition > 0) then begin
BarsSinceEntry = 0 の場合、開始
LongPT = 0;
LongSL = Round2Fraction(EntryPrice – (5.88 * AvgTrueRange(109)[0]));
終了;;

 

// Profit trailing
PriceLevel = Round2Fraction((3.23 * AvgTrueRange(126)[0]));
if(PriceLevel > 0) then begin
PriceLevel = Close – PriceLevel;
if(LongSL = 0 or LongSL < PriceLevel) then
LongSL = PriceLevel;
終了;;

if(LongPT > 0) then
Sell(“LongPT”) next bar at LongPT limit;
if(LongSL > 0) then
Sell(“LongSL”) next bar at LongSL stop;
終了;;

// Short ——–
if(MarketPosition < 0) then begin
BarsSinceEntry = 0 の場合、開始
ShortPT = 0;
ShortSL = Round2Fraction(EntryPrice + (5.88 * AvgTrueRange(109)[0]));
終了;;

 

// Profit trailing
PriceLevel = Round2Fraction((3.23 * AvgTrueRange(126)[0]));
if(PriceLevel > 0) then begin
PriceLevel = Close + PriceLevel;
if(ShortSL = 0 or ShortSL > PriceLevel) then
ShortSL = PriceLevel;
終了;;

if(ShortPT > 0) then
BuyToCover(“ShortPT”) next bar at ShortPT limit;
if(ShortSL > 0) then
BuyToCover(“ShortSL”) next bar at ShortSL stop;
終了;;

if(ExitOnClose) then
SetExitOnClose;

 

It’s OK when strategy using fixed pips. They have same effort.

But when we use ATR’s SL and PT setting, The two method didn’t do the same thing.

In SQX’s style, the SL and PT value would be changed bar by bar, because the ATR is not the fixed one.

I don’t like this new method, and is this a bug?

 

0

Tomas Matejka

管理者、sq-ultimate、2件の返信.

プロフィールを表示

7年前 #240493

こんにちは,

there have been modifications done to TS code compared to SQ3. If you have issues with a strategy SL/PL when ATR is used please attach it into our roadmap so developers can check it https://roadmap.strategyquant.com/projects/sq4/tasks

0

イーストピース

Customer、bbp_participant、community、sq-ultimate、298件の返信。.

プロフィールを表示

7年前 #242341

Hello, Tomas,

Here is the post in the task of roadmap. Would you please check it? I think it’s a basic and important issue.

 

https://roadmap.strategyquant.com/tasks/sq4_5100

0

Tomas Matejka

管理者、sq-ultimate、2件の返信.

プロフィールを表示

7年前 #242343

Thanks, developers will check the issue and resolve as soon as possible

0

マーク・フリック

管理者、sq-ultimate、2件の返信.

プロフィールを表示

7年前 #242377

I understand your point, but it is like this on purpose and it is because of money management.

 

See, if you have MM to risk for example 5% of your account balance, it is computed from Stop Loss. So that you’ll lose only 5% when your SL is hit.

This is why we need SL to be computed at the time when trade is placed, and it cannot be dynamically recomputed every bar.

 

 

 

マーク
StrategyQuantアーキテクト

0

イーストピース

Customer、bbp_participant、community、sq-ultimate、298件の返信。.

プロフィールを表示

7年前 #242408

You are right, Mark. I agree with you in the first half.

And in the TS/MC code now , the SL level and PT target is truly changed every bar when it hold position. You can print the SL/PT value in MC .  Please checked it again.

With Stop entry order, we know the entry price firstly.   A little trouble when using Market order. In bar by bar mode of MC, it can’t compute the SL/PT with ATR at the same time of entry.

We can assume that the entry price is the close of   previous signal bar.

 

if marketpostion<>0  then begin

print(“date: “,date,”,mp=”,marketposition,”,entryprice=”,entryprice,”,atr=”,SQ_ATR(20)[1],”,sl=”,LongSL);

終了

0

5件の返信を表示中 - 1 - 5件目 (全5件中)