Scalping code help

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #12130 quote
    Elsborgtrading
    Participant
    Veteran

    Hi guys.

    I was attending this webinar that explained a scalping method I’d like to code. It was on FTSE 100, 5 min chart. The idea was to find the ATR from a specific rule set.

    the ruleset was to ignore the first and last two candle on a trading day between 08:00 and 16:30  on a 45 days basis. to make it easy it would yield 5.5 points (we can always try and code this later)

    To make a long trade, you should look for a bullish candle with no or almost no shadow 2×5.5=11 points and enter the trade there.

    Take profit would be around 5 but if the priceaction crosses under the low from the condition candle- then exit the trade

    Since this can easily be under 10 we cannot use stop loss, as IG would only allow >=10 as stop loss.

    But I cannot get the code to work with this exit- please help 🙂

    cheers Kasper

    defparam flatbefore=080000
    defparam flatafter=163000
    
    IF (Time >= 081000 AND Time <= 162000)then 
    Tradetime=1
    else
    Tradetime=0
    endif
    
    MyATR = 5.5
    
    
    bullbar=(close[0]-open[0])>=MyATR*2 //and close+1>=high// and open-2<=low
    
    
    
    IF NOT LongOnMarket AND bullbar and tradetime THEN
    BUY 1 CONTRACTS AT MARKET
    bulllow=low[0]
    if low crosses under bulllow and tradetime THEN
    SELL 1 contract AT MARKET
    ENDIF
    endif
    
    
    // Conditions to exit long positions
    //If low crosses under bulllow and tradetime THEN
    //SELL 1 contract AT MARKET
    //ENDIF
    SET TARGET PROFIT 5
    graph bulllow COLOURED(50,50,75) AS "xxxx"
    #12144 quote
    JC_Bywan
    Moderator
    Master

    I’d say that’s because once your code has bought one contract, at next candle you don’t enter anymore inside the “if not longonmarket and…” if statement, because you’re long now… So the “if low crosses under bulllow…” if statement is not visited during subsequent candles, you need to get it out of the “if not longonmarket”, something like:

    IF NOT LongOnMarket AND bullbar and tradetime THEN
    BUY 1 CONTRACTS AT MARKET
    bulllow=low
    ENDIF
    
    if low crosses under bulllow and tradetime and longonmarket THEN
    SELL 1 contract AT MARKET
    endif
    
    

    Also, Nicolas wrote interesting stuff about pending orders, but I can’t remember if I saw it as a forum response or a blog article, maybe you could use this type of order instead for your exit under bulllow.

    That’s the doc: http://www.prorealcode.com/documentation/stop-pending/

    So maybe a “sell 1 contract at bullow stop” order? Keeping in mind it has to be coded in such a way that the order is re-placed at each new candle (so careful with fancy if statement conditions that could sometimes place it and sometimes not while you’d still want it there at each bar you’re still long).

    #12145 quote
    Elsborgtrading
    Participant
    Veteran

    Hi Noobywan and thanks for your reply. Unfortunate I started out with your suggestion but with no different. Maybe we need ver 10.3 so that we can test for the exit on a 1 min chart. Perhaps this is the reason it will never hit as it’s the same cycle. Maybe It will never cross over in the same candle, but just be over. Pending orders I think will have the same problem with distance, at least on IG. I saw many time that the entry was to close to the price so the order was rejected.

    #12147 quote
    Nicolas
    Keymaster
    Master

    Your problem is that the actual low can’t cross its own value and that’s you are testing at line 20.

    #12150 quote
    JC_Bywan
    Moderator
    Master

    Nicolas has the sharpest eye!

    #12227 quote
    Elsborgtrading
    Participant
    Veteran

    Yes he has:-) and it working with your code, however it’s not a good strategy. Progressing the strategy I found out if I use a “set stop loss 2” the code will work if slightly changes, however IG does not allow small STOP contracts, so is there a way around? I want to save the number from the entry point, the “CONTRACT AT MARKET” price and test on it later. something like this, however it not working: Basically  I’m looking for at way to code a SL at 2 without using the SET STOP LOSS 2. can it be done, or perhaps on multiple timeframes in ver 10.3?

    MyATR1 = x1
    MyATR2 = x2
    
    bullbar=MyATR2*2>=(close[0]-open[0])and (close[0]-open[0])>=MyATR1*2 //and close+1>=high// and open-2<=low
    
    
    
    IF bullbar and tradetime THEN
    BUY positionsize CONTRACTS AT MARKET
    //bulllow=low[0]
    //bullopen=open[0]-3
    endif
    
    if low crosses under open[0]-2 and tradetime THEN //intension to stop if -2 point from buy at marked value
    SELL AT MARKET
    ENDIF
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Scalping code help


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by Elsborgtrading
9 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/23/2016
Status: Active
Attachments: No files
Logo Logo
Loading...