Basic code help required – market entry level
Forums › ProRealTime English forum › ProOrder support › Basic code help required – market entry level
- This topic has 7 replies, 3 voices, and was last updated 7 years ago by JC_Bywan.
-
-
02/17/2017 at 10:24 AM #25372
Hi,
I am in need of some help if possible.
I am sure there is an easy answer to my issue, i have read the PDF manuals and unfortunately still stuck.
I have a simple entry….
IF not longonmarket THEN
BUY 1 PERPOINT AT MARKET
ENDIFwhat i want to do now is if my buy position reaches 20 pips in profit, to increase the position by £1.
so what command tells you the level of your entry to the market? then i can use something like IF close > “market entry” + 20 THEN BUY 1 PERPOINT AT MARKET ENDIF
But how do you know exactly the level you got in at ?
Any help is appreciated
02/17/2017 at 10:49 AM #25375What you call “market entry” is the price level where the last trade entry was made.
You can retrieve it easily with the TRADEPRICE instruction.
In your case, the example you’ll find in this documentation page is exactly what you need: Example of a simple trading strategy using MACD crossing above and below the zero line with adding orders while the price continue to get higher.
Hope it helps.
02/17/2017 at 12:25 PM #25389Thanks for your help. I have tried this but cant get it to work.
Below is my test code to get TRADEPRICE to work.
What should happen is that i enter the market long at £1 Stop 20 pips, when the price is over 5 pips in profit it adds another £2 to the position and charnes the stop from 20 to 10 pips.
What happens when i run the code below is it doesn’t wait for price to be above 5 pips, but enters the market at £3 and the stop is at 10.
123456789101112DEFPARAM CumulateOrders = TrueIF not longonmarket THENBUY 1 Shares AT MARKETset target pProfit 20set stop ploss 20ENDIFIF close - tradeprice(1) > 5 thenbuy 2 Shares AT MARKETset stop ploss 10ENDIF02/17/2017 at 1:00 PM #2539202/17/2017 at 1:02 PM #2539302/17/2017 at 1:20 PM #2539402/17/2017 at 1:26 PM #2539602/17/2017 at 1:26 PM #25397Probably need to add “if longonmarket” too in the second if statement, otherwise when you’re not longonmarket and close is more than 5 points above last trade close, the “buy 2” will happen at the same candle as the first “buy 1” (keep in mind tradeprice(1) is not “always” the last entry and is not nothing when there’s no ongoing entry, it is by definition the last price trading action whatever it was, so when you’re not longonmarket tradeprice(1) is worth last trade close, or last short entry if there are shorts too).
So line 9 would become :
1IF longonmarket and (close - tradeprice(1)) > 5 then -
AuthorPosts