DEV Community

Tyler Francis
Tyler Francis

Posted on

How to Build a Pine Script Strategy That Passes Prop Firm Evaluation

So I spent a while getting burned on prop firm evaluations before I figured this out. The issue was that my Pine Script was not built with prop firm rules in mind. Most scripts you find online are not. Here is what actually needs to be in your code.

Daily Loss Lock

This is the big one. Your script has to stop trading automatically if you hit the firm daily drawdown. Do not rely on yourself to close manually — you will miss it eventually.

On Apex that is $2,500 on a $50k account. Topstep is only $1,000. Code it in:

var float dayStart = na
if dayofweek != dayofweek[1] or na(dayStart)
    dayStart := strategy.equity
float dailyPnL = strategy.equity - dayStart
if dailyPnL <= -2500
    strategy.close_all("daily loss limit hit")
Enter fullscreen mode Exit fullscreen mode

End of Day Flatten

Every prop firm requires you to be flat before session close. 3:55pm CT for CME futures.

if hour == 15 and minute >= 55 and strategy.position_size != 0
    strategy.close_all("EOD flatten")
Enter fullscreen mode Exit fullscreen mode

Apex vs Topstep for algos

Apex has no consistency rule at all. Topstep caps your best single day at 30% of your total eval profit. If your algo has a great trending day it can actually hurt you on Topstep. I break this down at propfirmpinescripts.com.

Pre-built compliant scripts

If you want scripts that already have all this coded in, they are at propfirmpinescripts.com. The bundle includes 4 strategies for GC, MES, MNQ, and CL — all with EOD flatten, daily loss locks, and win locks built in.

Top comments (0)