Reply

Help with Shift definition

4 replies

eawNewbie

Customer, bbp_participant, community, 11 replies.

Visit profile

9 years ago #113451

I also don’t fully understand what you want to achieve, but you can use Shift parameter.

 

Shift = 0 means value at current bar, Shift = 1 means indicator value on previous bar and so on.

Shift = 9 means indicator value 9th bar back.

I quoted this from another thread.  The thread was not applicable to my issue but this post is, so i hope that is ok to quote it

 

 

I understand that shift = 0 means the current bar (eg: bar in progress),  what isn’t clear is “value at current bar” ??

 

Does the last statement “Shift = 0 means value at current bar” mean the price/value at the precise event time during the current bar’s timeframe?

 

I’ve been looking for a complete definition of shift ever since both here and at MQL5

 

 

I came accross this problem when attempting to open a position after the current bar is atleast 3 pips higher than the preceeding bar’s high.

 

meanwhile will this code function as desired?

 

//Var

Offset=3

 

//rule

And (High[0] > (High[1] + ConvertToRealPips(Offset))

 

 

thanks

0

eawNewbie

Customer, bbp_participant, community, 11 replies.

Visit profile

9 years ago #129243

I could not get the condition rule above to work so I decided to remove it and apply an “enter at stop order” instead using this code

 

      // Action
      sqOpenOrder(“NULL”, OP_BUYSTOP, getOrderSize(MagicLong, OP_BUYSTOP ), getOrderPrice(MagicLong), “”, MagicLong, “OffsetBuy”);
 

 

Unfortunately this fails also, so i’m doing something wrong.. ??

0

Mark Fric

Administrator, sq-ultimate, 2 replies.

Visit profile

9 years ago #129245

yes, by using Shift = 0 in High, Low or indicators you’ll get their values at that specified time when the function was called.

 

When I test your condition

And (High[0] > (High[1] + ConvertToRealPips(Offset))

 

it works correctly, what doesn’t work for you? Does it open at different times than expected?

 

Or doesn’t it open trades at all? then check error log if there isn’t some error, trade size errors are quite usual.

Mark
StrategyQuant architect

0

eawNewbie

Customer, bbp_participant, community, 11 replies.

Visit profile

9 years ago #129287

Thanks for your confirmation on Shift.

 

When I use the rule above, the condition doesn’t appear to be met as every action after the “then” does not get parsed.  I can not find any clues as to why from reading the logs, even with verbose = 2  as if there is no error just the condition does not return true.

 

I removed the condition and trades are opened as expected.   The condition filters out all opportunities during the backtesting period, I’ll have to verify the condition actually exists in the test period.    Without the condition I get literally hundreds of trades, with the condition results in zero trades.

 

If you say there is no issue with the condition structure then I’ll check manually that the condition actually exists.   Maybe I’ll try changing “is greater than” to “is less than”

 

Which is faster, check for the condition within the If statment? or check for the condition by changing the open at market command to open at stop and perform the test if the stop is reached within the “then statement?   I have found that adding the command within the “then construct” the action is not performed yet the next action is performed.

0

eawNewbie

Customer, bbp_participant, community, 11 replies.

Visit profile

9 years ago #129288

Ok I tried again and the condition is working

 

not sure what happened there 

thanks

0

Viewing 4 replies - 1 through 4 (of 4 total)