ScrewTurn

Active Trader Strategies API Community ChartStyles Community Commissions Community Components Community Indicators Knowledge Base Misc Optimizers PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation







Quick Search
»
Advanced Search »

PoweredBy

Syntax


public int GetTime(int bar)

Parameter Description

bar Bar number

GetTime returns 24-hour time as an integer. Example: 4pm = 1600


Syntax


public int AddIntegerTime( int t, int minutes )

Parameter Description

t Integer time e.g. 1600
minutes Minutes to subtract e.g. 5

AddIntegerTime adds minutes to an integer time (HHnn) and returns a HHnn time. Example 1600 - 5 = 1555


Syntax


public int FirstBarofDay( int startDay )

Parameter Description

startDay Day number

FirstBarofDay returns the chart bar number of the first bar of the startDay. Example: Pass 2 to get the first bar of the second day


Syntax


public int DaysInPosition(int bar, Position p)

Parameter Description

bar Bar number
p Position object

DaysInPosition returns how many days have passed since establishing a position using intraday data.



Description

Intraday support functions and methods created by Robert Sucher. They are often required for intraday strategies.

GetTime returns 24-hour time as an integer. Example: 4pm = 1600
AddIntegerTime adds minutes to an integer time (HHnn) and returns a HHnn time. Example 1600 - 5 = 1555
FirstBarofDay returns the chart bar number of the first bar of the startDay. Example: Pass 2 to get the first bar of the second day
DaysInPosition returns how many days have passed since establishing a position using intraday data.


Example


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; // Intraday support functions here

namespace WealthLab.Strategies { public class MOCStrategy : WealthScript { /* Sliders * minTradeBars are the min number of bars before the end of day that an entry is allowed */ private StrategyParameter todayCloseTime; private StrategyParameter minTradeBars; public MOCStrategy() { todayCloseTime = CreateParameter("Close Today", 1600, 1300, 1600, 300); minTradeBars = CreateParameter("Min Trade Bars", 5, 2, 10, 1); } protected override void Execute() { // Intraday support functions here: Utility u = new Utility( this ); int todayClose = todayCloseTime.ValueInt; int minBarsInTrade = minTradeBars.ValueInt; int lastChartBar = Bars.Count - 1; int nextToLastBarTime = u.AddIntegerTime( todayClose, -Bars.BarInterval ); for(int bar = u.FirstBarofDay( 2 ); bar < Bars.Count - 1; bar++) { if( !IsLastPositionActive ) { if ( bar < lastChartBar - minBarsInTrade ) { BuyAtLimit(bar + 1, Bars.Low[bar] * 0.995); } } else { Position p = LastPosition; if( (bar == lastChartBar) && (u.GetTime(bar) >= nextToLastBarTime) ) { SetBarColor( bar, Color.Orange); ExitAtMarket( bar + 1, p, "Exit at open of last bar"); } else if ( (bar != lastChartBar) && Bars.IsLastBarOfDay(bar + 1) ) { SetBarColor( bar, Color.Orange); ExitAtMarket( bar + 1, p, "Exit at open of last bar"); } else { // other exit logic here } } } } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki version 3.0.2.509. Some of the icons created by FamFamFam.