Forums › ProRealTime English forum › General trading discussions › Create strategies codes with ChatGPT for ProRealTime › Reply To: Create strategies codes with ChatGPT for ProRealTime
06/01/2023 at 8:08 PM
#215562
This was my initial ask –
Code me a strategy for DAX in the 5 min timeframe. During the opening 3 hours buy when price crosses over the highest price since 1am and vice versa for sell. Profit target is 5pips and stop loss is the low of the previous bar
I had to correct it a few times by saying for eg –
– there is no when function, recode the dax strategy
– this code does not work
I think we can make the prompt better by giving it most commonly used functions and a few simple examples.
Still testing
this is what it gave me initially –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
defparam cumulateOrders = false defparam flatafter = 235959 // prevent any overnight trades TimeFrame = 5 // define opening period startHour = 080000 // DAX opens at 8:00 local time endHour = 110000 // ends at 11:00 local time priorHour = 010000 // 1:00 am as per your request // variables for highest price and lowest price since 1 am highestPrice = max[BarIndex](high) when time >= priorHour and time < startHour lowestPrice = min[BarIndex](low) when time >= priorHour and time < startHour // if current time is within the opening hours and price crosses over the highest price since 1am then buy if time >= startHour and time <= endHour and close crosses over highestPrice then buy at market set stop ploss abs(low[1]-close) / pointsize set target pprofit 5 * pointsize endif // if current time is within the opening hours and price crosses under the lowest price since 1am then sellshort if time >= startHour and time <= endHour and close crosses under lowestPrice then sellshort at market set stop ploss abs(high[1]-close) / pointsize set target pprofit 5 * pointsize endif |