NexusFi: Find Your Edge


Home Menu

 





NEED HELP TO WRITE MY FIRST STRATEGY


Discussion in NinjaTrader

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




 
Search this Thread

NEED HELP TO WRITE MY FIRST STRATEGY

  #1 (permalink)
 benwincky 
Brussels Belgium
 
Experience: Beginner
Platform: Ninjatrader
Broker: GAINCAPITAL/Forex.com
Trading: Forex
Posts: 14 since Mar 2013
Thanks Given: 5
Thanks Received: 0

Hello to you

I can manipulate my edit script by now

But I'm nowhere, let's be honnest. There are so many commands that you would save me time indicating me whitch set of command I could Start with for my first «own scrpit*»

I read a lot in the forum but didn't find what I want or maybe came accross without noticing that was the command Iwas looking for.

I will give and example I think this is the best way

I intend working this way

protected override void Initialize()
{

CalculateOnBarClose = False;
}

I'm not interested in bars closed though I know it is CPU intensive

I have the EURJPY a 120,55

I will write this example for a long entry but the logic would be the same if I would go short

As I enable my strategy, I want this 120,55 value stored in a «*double*» variable

(This is my first problem, I have been unable to find a way for doing so)


Let's say The EURJPY moves up 1 pip up to 120,56

At time I want to start a stop watch to 0 second


First case

The EURJPY moves up 4 more pips to 120,60 within 3 seconds, I would enter long

Second Case

3 seconds have elapsed and the EURJPY moved up to 120,59

It didn't fill my condtions to enter long and the stop watch resets to Zero

Third Case

The EURJPY went up to 120,58 and then back down to 120,57. Well, it didn't fill my conditions either

But....

It might be a new begining of a short entry process

I went down one pip, didn't he*?

I now want the 120,58 stored in my double Variable and restart a stop wath to Zero

And If the EURJPY moved down within 3 second I enter Short.

TO REPHASE THIS IN SHORT

1. How to I do To get the Actual Value of the EURJPY in a variable as I start my strategy.
2. How do I start a stop watch

Thanks in advance



Benwinckelmans

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Tao te Trade: way of the WLD
24 thanks
Diary of a simple price action trader
21 thanks
My NQ Trading Journal
14 thanks
HumbleTraders next chapter
10 thanks
  #3 (permalink)
 
MrYou's Avatar
 MrYou 
NC, USA
 
Experience: None
Platform: None Yet
Trading: Guitar
Posts: 403 since Jun 2011
Thanks Given: 618
Thanks Received: 196


My suggestion is to forget about this "stop watch" stuff. You need to understand how charts and NinjaScript work. I can't explain it all, but below is some simple code.

Add() a 3 second chart or base your primary bars (BarsInProgress == 0) off the 3 second chart.

CalculateOnBarClose = true;

 
Code
if (BarsInProgress == 0)
{
   if (Close[0] - Open[0] > TickSize * 3)
     EnterLong();
}
OR for Multi-Timeframe: Add(PeriodType.Second, 3)

 
Code
if (Closes[1][0] - Opens[1][0] > TickSize * 3)
  EnterLong();

Reply With Quote
Thanked by:




Last Updated on April 2, 2013


© 2024 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 - Privacy Policy - Downloads - Top
no new posts