Scalping code help
Forums › ProRealTime English forum › ProOrder support › Scalping code help
- This topic has 5 replies, 3 voices, and was last updated 8 years ago by Elsborgtrading.
-
-
08/23/2016 at 3:09 PM #12130
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
12345678910111213141516171819202122232425262728293031defparam flatbefore=080000defparam flatafter=163000IF (Time >= 081000 AND Time <= 162000)thenTradetime=1elseTradetime=0endifMyATR = 5.5bullbar=(close[0]-open[0])>=MyATR*2 //and close+1>=high// and open-2<=lowIF NOT LongOnMarket AND bullbar and tradetime THENBUY 1 CONTRACTS AT MARKETbulllow=low[0]if low crosses under bulllow and tradetime THENSELL 1 contract AT MARKETENDIFendif// Conditions to exit long positions//If low crosses under bulllow and tradetime THEN//SELL 1 contract AT MARKET//ENDIFSET TARGET PROFIT 5graph bulllow COLOURED(50,50,75) AS "xxxx"08/23/2016 at 8:42 PM #12144I’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:
12345678IF NOT LongOnMarket AND bullbar and tradetime THENBUY 1 CONTRACTS AT MARKETbulllow=lowENDIFif low crosses under bulllow and tradetime and longonmarket THENSELL 1 contract AT MARKETendifAlso, 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).
08/23/2016 at 9:15 PM #12145Hi 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.
08/23/2016 at 9:29 PM #1214708/23/2016 at 10:29 PM #1215008/25/2016 at 7:26 PM #12227Yes 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?
12345678910111213141516MyATR1 = x1MyATR2 = x2bullbar=MyATR2*2>=(close[0]-open[0])and (close[0]-open[0])>=MyATR1*2 //and close+1>=high// and open-2<=lowIF bullbar and tradetime THENBUY positionsize CONTRACTS AT MARKET//bulllow=low[0]//bullopen=open[0]-3endifif low crosses under open[0]-2 and tradetime THEN //intension to stop if -2 point from buy at marked valueSELL AT MARKETENDIF -
AuthorPosts