NexusFi: Find Your Edge


Home Menu

 





Hammer script


Discussion in NinjaTrader

Updated
    1. trending_up 2,643 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 zebidee 
London
 
Experience: Intermediate
Platform: Ninjatrader, T4
Trading: Nasdaq
Posts: 5 since Feb 2013
Thanks Given: 1
Thanks Received: 0

Hi all

I am new to Ninjascript and trying to create a really basic script based around price action, but the script doesn't execute. The idea is simply to trigger a long trade on a hammer candlestick formation. Ideally, I would like to add a bullish engulfing/morning star to this on the same basis. This is what I have:

{
SetProfitTarget("", CalculationMode.Ticks, 42);

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (Close[0] + 5 * TickSize > Low[0]
&& ToTime(Time[0]) >= ToTime(8, 0, 0)
&& ToTime(Time[0]) <= ToTime(17, 0, 0))
{
EnterLong(1, "");
}

}

thanks for any help


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
No book, only a stair: journaling fills where price move …
Cryptocurrency
My Rant with AMP Futures
Trading Reviews and Vendors
Building a free browser DOM/SMC simulator - need some ad …
Platforms and Indicators
Bitcoin’s 2022 low, 2025 high and 2026 low so far arou …
Cryptocurrency
AI for Traders — Agents, Memory, Tools & Real-Worl …
Elite Quantitative GenAI/LLM
 
  #3 (permalink)
 
sam028's Avatar
 sam028 
Site Administrator
 
Posts: 3,779 since Jun 2009
Thanks Given: 3,840
Thanks Received: 4,709


Try in adding a Print() to see what are the values of your conditions:

 
Code
                            
Print("C: "+ Close[0] + 5 * TickSize+" Low: "+ Low[0] + " T1: "+ ToTime(Time[0]).toString() .... 

If you never execute the EnterLong(), it's because your conditions are never met...


Success requires no deodorant! (Sun Tzu)
Reply With Quote
  #4 (permalink)
 zebidee 
London
 
Experience: Intermediate
Platform: Ninjatrader, T4
Trading: Nasdaq
Posts: 5 since Feb 2013
Thanks Given: 1
Thanks Received: 0

Thanks for that. I'm afraid I'm pretty much limited to using the wizard and got an error when I tried to add that code. But, I have compiled a new script to enter long when the high is 1 tick above the low and it doesn't, so there seems to be something else wrong. Other scripts are executing fine.


Started this thread Reply With Quote




Last Updated on February 27, 2013


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts