Spike Straddle Strategy

If you need an Indicator or Signal developed or translated from other language, please post all Indicator development REQUESTS to this section here.

Moderator: admin

Spike Straddle Strategy

Postby KevinH » Fri Jul 10, 2020 11:56 am

HI, been going round in circles trying to code up a strategy in lua. Perhaps you could help me so I get back to good foundation of code. Thanks!
1) Setup Parameters:
    a. Timeframe: Default 1H
    b. CandleSize: a percentage, default 150%
    c. StradleSize: a percentage, default 10%
    d. Stoploss: a percentage, default 50%
    e. TakeProfit: a percentage, default 50%
2) Signal Trigger Condition: Body of last candle > ‘CandleSize’ * ATR(11)

3) Two Entry orders placed on trigger to straddle the candle close,
    a. one long placed ‘StradleSize’ * ATR above the candle close;
    b. one short placed ‘StradleSize’ * ATR below the candle close.
    c. Stop loss set at ‘Stoploss’ * ATR (for both orders)
    d. Limit Order set at ‘TakeProfit’ * ATR (for both orders)
4) Activated trade cancels the other trade. So if the Long kicks in, the short is cancelled. If the short activates, the long is removed.

5) No need for multiple trade checking. No trade expiry needed; no other indicators except ATR.

Please see the attached image that hopefully will show what I mean.

Once I have got some good code for the above then I can modify it into what want.
Thanks
Attachments
Image 2020-07-10 15 46 11.jpg
KevinH
 
Posts: 7
Joined: Sun Jun 07, 2020 4:45 pm

Re: Spike Straddle Strategy

Postby Apprentice » Sat Jul 11, 2020 4:32 pm

Your request is added to the development list.
Development reference 1681.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Re: Spike Straddle Strategy

Postby KevinH » Tue Jul 14, 2020 6:02 pm

Thanks for doing that so quick.

Seems to have an issue with the ATR though:
ERROR " attempt to index global 'source' (a nil value)" in file "C:/Gehtsoft/IndicoreSDK3/strategies/Spike Straddle Strategy.lua" at line #310
Debug session is finished

(Thats from the Indicore IDE)
KevinH
 
Posts: 7
Joined: Sun Jun 07, 2020 4:45 pm

Re: Spike Straddle Strategy

Postby Apprentice » Wed Jul 15, 2020 10:17 am

What this in backtesting or on Live/Demo?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Spike Straddle Strategy

Postby KevinH » Wed Jul 15, 2020 12:16 pm

Initially I tried it on the simulator and then the IDE (the message I gave is from the IDE).

Changed lines 310 & 312 to the following seemed to fix it, so typo in the stream name?

valuemap.Rate = main_source.close[NOW] + atr.DATA[NOW] * StradleSize / 100.0;
KevinH
 
Posts: 7
Joined: Sun Jun 07, 2020 4:45 pm

Re: Spike Straddle Strategy

Postby KevinH » Wed Jul 15, 2020 2:53 pm

Another issue is that it seems to be placing the entry orders during the formation of the candle, not at the close of the candle. It is the latter that I want please.

This is what I saw in the TS2 Simulator. In the attached screen grab, the simulator is at 3:27 and the trade was placed (Entry order was a little before that, but I was not quick enough to capture it).

As this is the hourly chart, the EOs should only be placed on the hour at candle change.

Thanks
Attachments
Image 2020-07-15 19 01 18.jpg
KevinH
 
Posts: 7
Joined: Sun Jun 07, 2020 4:45 pm

Re: Spike Straddle Strategy

Postby KevinH » Thu Jul 16, 2020 5:03 am

Oh, and I figured out the end of candle trade issue, needed to set entry_execution_type to "EndOfTurn" instead of Live.

So Strat is working for me now. Many thanks.
KevinH
 
Posts: 7
Joined: Sun Jun 07, 2020 4:45 pm

Re: Spike Straddle Strategy

Postby Apprentice » Fri Jul 17, 2020 5:18 am

Yes, You need to shift the period to -1 for use end of turn.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36435
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Indicator and Signal Requests

Who is online

Users browsing this forum: Bing [Bot] and 22 guests