Basic code help required – market entry level

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #25372 quote
    pips_103
    Participant
    Average

    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
    ENDIF

    what 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

    #25375 quote
    Nicolas
    Keymaster
    Master

    What 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.

    #25389 quote
    pips_103
    Participant
    Average

    Thanks 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.

     

    DEFPARAM CumulateOrders = True
    
    IF not longonmarket THEN
    BUY 1 Shares AT MARKET
    set target pProfit 20
    set stop ploss 20
    ENDIF
    
    IF close - tradeprice(1) > 5 then
    buy 2 Shares AT MARKET
    set stop ploss 10
    ENDIF
    #25392 quote
    Nicolas
    Keymaster
    Master

    What instrument please?

    #25393 quote
    pips_103
    Participant
    Average

    I am testing on GBPEUR on a 1 min candle chart with ProRealtime V10.3

    #25394 quote
    Nicolas
    Keymaster
    Master

    Ok so 5 is 5,00000 pips!

    You’d better use ‘pointsize’ instruction to convert this value correctly to the current instrument like in this example :

    IF close – tradeprice(1) > 5*poinsize then

    #25396 quote
    pips_103
    Participant
    Average

    Hi Thanks Nicolas, however for me this still doesn’t work, and enters directly at £3 and reduces the stop on market entry

    #25397 quote
    JC_Bywan
    Moderator
    Master

    Probably 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 :

    IF longonmarket and (close - tradeprice(1)) > 5 then
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Basic code help required – market entry level


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
pips_103 @pips_103 Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by JC_Bywan
9 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/17/2017
Status: Active
Attachments: No files
Logo Logo
Loading...